Structured, temporal memory for AI agents.
Project description
memv
/mɛm-viː/ · Structured, temporal memory for AI agents
Docs • Getting Started • PyPI
Most memory systems extract everything and rely on retrieval to filter it. memv extracts only what the model failed to predict — importance emerges from prediction error, not upfront scoring.
| Typical Approach | memv |
|---|---|
| Extract all facts upfront | Extract only what we failed to predict |
| Overwrite old facts | Invalidate with temporal bounds |
| Retrieve by similarity | Hybrid vector + BM25 + RRF |
| Timestamps only | Bi-temporal: event time + transaction time |
Quick Start
uv add memvee
# or: pip install memvee
from memv import Memory
from memv.embeddings import OpenAIEmbedAdapter
from memv.llm import PydanticAIAdapter
memory = Memory(
db_url="memory.db", # or "postgresql://user:pass@host/db"
embedding_client=OpenAIEmbedAdapter(),
llm_client=PydanticAIAdapter("openai:gpt-4o-mini"),
)
async with memory:
await memory.add_exchange(
user_id="user-123",
user_message="I just started at Anthropic as a researcher.",
assistant_message="Congrats! What's your focus area?",
)
await memory.process("user-123")
result = await memory.retrieve("What does the user do?", user_id="user-123")
print(result.to_prompt())
Features
Predict-Calibrate Extraction · Only extracts what the model failed to predict. Based on Nemori.
Bi-Temporal Validity · Track when facts were true (event time) vs when you learned them (transaction time). Based on Graphiti.
Hybrid Retrieval · Vector similarity + BM25 text search with Reciprocal Rank Fusion.
Episode Segmentation · Groups messages into coherent conversation episodes.
Contradiction Handling · New facts invalidate conflicting old facts. Full audit trail preserved.
SQLite + PostgreSQL · SQLite for local dev, PostgreSQL with pgvector for production. Set db_url to choose between them.
Multiple Embedding Providers · OpenAI, Voyage, Cohere, or local via fastembed. Dimensions detected from the adapter.
Point-in-Time Queries
memv's bi-temporal model lets you query knowledge as of a specific point in time:
from datetime import datetime
# What did we know about user's job in January 2024?
result = await memory.retrieve(
"Where does user work?",
user_id="user-123",
at_time=datetime(2024, 1, 1),
)
# Show full history including superseded facts
result = await memory.retrieve(
"Where does user work?",
user_id="user-123",
include_expired=True,
)
Architecture
Messages → Episodes → Knowledge → Vector Index + Text Index
(sqlite-vec / pgvector) (FTS5 / tsvector)
- Messages buffered until threshold
- Segmented into coherent episodes
- Predict what episode should contain (given existing KB)
- Compare prediction vs actual — extract the gaps
- Store with embeddings + temporal bounds
Framework Integration
class MyAgent:
def __init__(self, memory: Memory):
self.memory = memory
async def run(self, user_input: str, user_id: str) -> str:
context = await self.memory.retrieve(user_input, user_id=user_id)
response = await self.llm.generate(
f"{context.to_prompt()}\n\nUser: {user_input}"
)
await self.memory.add_exchange(user_id, user_input, response)
return response
See Examples for PydanticAI, LangGraph, LlamaIndex, CrewAI, and AutoGen integrations.
Documentation
- Getting Started — First example and agent pattern
- Core Concepts — Predict-calibrate, episodes, bi-temporal, retrieval
- Backends — SQLite and PostgreSQL setup
- API Reference — All public classes and methods
Contributing
git clone https://github.com/vstorm-co/memv.git
cd memv
make install
make all
See CONTRIBUTING.md for details.
MIT — see LICENSE
Built by vstorm
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file memvee-0.1.2.tar.gz.
File metadata
- Download URL: memvee-0.1.2.tar.gz
- Upload date:
- Size: 48.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2b489999eed55bae612e9efb19e2c69a336784e3a1614a7eafceb2765126c98
|
|
| MD5 |
5c9989a1fe00d0d6a8d9d9ea963824f0
|
|
| BLAKE2b-256 |
81f858445cd463cbe99b372db068a60a494987254e1f15c96a97b351c15dfaff
|
Provenance
The following attestation bundles were made for memvee-0.1.2.tar.gz:
Publisher:
publish.yml on vstorm-co/memv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memvee-0.1.2.tar.gz -
Subject digest:
b2b489999eed55bae612e9efb19e2c69a336784e3a1614a7eafceb2765126c98 - Sigstore transparency entry: 1199736428
- Sigstore integration time:
-
Permalink:
vstorm-co/memv@127deaaebf11e29ad9d38c5c24654addce1f3d39 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@127deaaebf11e29ad9d38c5c24654addce1f3d39 -
Trigger Event:
release
-
Statement type:
File details
Details for the file memvee-0.1.2-py3-none-any.whl.
File metadata
- Download URL: memvee-0.1.2-py3-none-any.whl
- Upload date:
- Size: 72.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c8819f4b597867848bdd30b1c2e1be79689452132e0269170d63c643f34640a
|
|
| MD5 |
01fcbec88d64d08daf67c0edf33bb604
|
|
| BLAKE2b-256 |
c069266f78b2c1bb80676facc433d4ab1a74a9a5cabd2f062d119ae75dafa372
|
Provenance
The following attestation bundles were made for memvee-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on vstorm-co/memv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memvee-0.1.2-py3-none-any.whl -
Subject digest:
7c8819f4b597867848bdd30b1c2e1be79689452132e0269170d63c643f34640a - Sigstore transparency entry: 1199736449
- Sigstore integration time:
-
Permalink:
vstorm-co/memv@127deaaebf11e29ad9d38c5c24654addce1f3d39 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@127deaaebf11e29ad9d38c5c24654addce1f3d39 -
Trigger Event:
release
-
Statement type: